import java.util.Arrays;

public class TestDemo {

    public static int Add(int a,int b){
        return  a+b;
    }
    public  static double Add(double a,double b){
        return a+b;
    }
    public static int max2(int a,int b){
        return a > b ? a: b;
    }
    public static int max3(int a,int b,int c){
        return max2(a,b)>c?max2(a,b):c;
    }


    public static void main2(String[] args) {
        System.out.println("hello");
    }
    public static void main1(String[] args) {
        System.out.println(Add(1.1, 2.2));
        System.out.println(Add(1, 2));
    }

    public static void main3(String[] args) {
        //数组的定义方式
        //静态初始化
        int []arry={1,2,3,4};
        //遍历数组
        for (int i = 0; i < 4; i++) {
            System.out.println(arry[i]);
        }
        //  System.out.println(arry[1]);
        //动态初始化
        int []arry1=new int[4];//默认是数字0
        int []arry2=new int[]{1,2,3,4};
    }

    public static void main4(String[] args) {
        //数组遍历--第一种打印方式
        int arry[]={1,2,3,4};
       /* int len=arry.length;//求数组长度
        for (int i = 0; i < len; i++) {
            System.out.print(arry[i]+" ");
        }
        System.out.println();*/
        //--数组遍历,第二种打印方式
        for(int x:arry){     //for each循环
            System.out.print(x+" ");
        }
        //第三种打印方式
        //把传入的数组转化为字符串的形式进行输出
        String ret=Arrays.toString(arry);
        System.out.println(ret);

    }

    public static void main5(String[] args) {
        int [] arry1={1,2,3,4};
        int [] arry2={9,8,7,6};
        System.out.println("交换前arry1数组"+Arrays.toString(arry1));
        System.out.println("交换前arry2数组"+Arrays.toString(arry2));
        int []tmp=arry1;
        arry1=arry2;
        arry2=tmp;
        System.out.println("交换后arry1数组"+Arrays.toString(arry1));
        System.out.println("交换后arry2数组"+Arrays.toString(arry2));
        int[] arr=null;
        System.out.println(arr);
    }
    public static void print(int[] arry){
        for (int i = 0; i < arry.length; i++) {
            System.out.print(arry[i]+" ");
        }
        System.out.println();
    }

    public static void main6(String[] args) {
        int[] arry={10,20,30};
        print(arry);
    }
    public static int []test(){
        int []ret=new int[2];
        ret[0]=1;
        ret[1]=2;
        return  ret;
    }

    public static void main7(String[] args) {
        int ret[]=test();
        System.out.println(Arrays.toString(ret));
    }

    public static String myToString(int[] array){
        String ret="[";

        for (int i = 0; i < array.length; i++) {
            ret+=array[i];
            if(i!=array.length-1){
                ret+=",";
            }
        }
        ret+="]";
        return  ret;
    }
    public static void main(String[] args) {
        int []array={10,20,30};
        String ret =myToString(array);
        System.out.println(ret);
    }
}